using System;
using System.Collections.Generic;

namespace DOJ.LEISP.LEXS.Common.Providers
{
    public class DefaultDataOwnerProvider : IDataOwnerProvider
    {
        public List<DataOwnerInformationType> GetDataOwners()
        {
            List<DataOwnerInformationType> dataOwners = new List<DataOwnerInformationType>();

            dataOwners.Add(GetDataOwner("AA1234567", "Hypothetical Agency A", "SysA", "Will", "Jones", "111-222-3333",true,true, new DataItemCategoryType { DataItemCategoryText = "Arrest", DataItemCategoryDescription = "Arrest Reports" }, new DataItemCategoryType { DataItemCategoryDescription = "Incident", DataItemCategoryText = "IncidentReports" }));
            dataOwners.Add(GetDataOwner("DD1234567", "Hypothetical Agency D", "SysD", "Will", "Dee", "222-222-3333", true,false,new DataItemCategoryType { DataItemCategoryText = "Field Interview", DataItemCategoryDescription = "Field Interviews" }));
            return dataOwners;
        }

        static DataOwnerInformationType GetDataOwner(string organizationAgencyId, string organizationName, string systemId, string contactGivenName, string contactSurName, string contactFullTelephone,  bool structuredSearch, bool textSearch, params DataItemCategoryType[] dataItemCategories)
        {
            DataOwnerInformationType dataOwner1 = new DataOwnerInformationType();
            List<DataItemCategoryType> dataOwner1Categories = new List<DataItemCategoryType>();
            Array.ForEach(dataItemCategories, item => dataOwner1Categories.Add(item));
            List<FullTelephoneNumberType> dataOwner1FullTelephoneList = new List<FullTelephoneNumberType>();
            dataOwner1FullTelephoneList.Add(new FullTelephoneNumberType { TelephoneNumberFullID = contactFullTelephone });
            List<ContactInformationType> dataOwner1ContactInfo = new List<ContactInformationType>();
            dataOwner1ContactInfo.Add(new ContactInformationType { Items = dataOwner1FullTelephoneList.ToArray() });

            dataOwner1.DataItemCategory = dataOwner1Categories.ToArray();
            dataOwner1.StructuredSearchIndicator = structuredSearch;
            dataOwner1.TextSearchIndicator = textSearch;
            dataOwner1.DataOwnerMetadata = new DataOwnerMetadataType
            {
                DataOwnerIdentifier = new DataOwnerIdentifierType
                    {
                        Item = organizationAgencyId,
                        ItemElementName = ItemChoiceType.OriginatingAgencyID,
                        OrganizationName = organizationName,
                        SystemID = systemId
                    },
                DataOwnerContact = new DataContactType
                    {
                        PersonGivenName = contactGivenName,
                        PersonSurName = contactSurName,
                        Items = dataOwner1ContactInfo.ToArray()
                    }
            };

            return dataOwner1;
        }
    }
}
